package com.wiscamp.ninechapters.threeparties.qiniu;

import cube.ddd.adapter.BaseController;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/api/ThreeParties")
@Tag(name = "第三方服务-七牛云")
public class QiniuController extends BaseController {
    private final QiniuService qiniuService;

    public QiniuController(QiniuService qiniuService) {
        this.qiniuService = qiniuService;
    }

    /*@PostMapping("files/actions/upload")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Operation(summary = "上传文件到七牛云")
    @HandleResourceException
    public RestResponse<String> uploadFile(@Context HttpServletRequest request, @Context HttpServletResponse response, @FormDataParam("file") InputStream uploadedInputStream,
                                           @FormDataParam("file") FormDataContentDisposition fileDetail) {
        try {
            var fileName = fileDetail.getFileName();
            var outputStream = new ByteArrayOutputStream();
            IOUtils.copy(uploadedInputStream, outputStream);
            var result = qiniuService.uploadFile(outputStream.toByteArray(), fileName);
            return ResourceHelper.getOkResponse(request, response, result);
        } catch (IOException ex) {
            return ResourceHelper.getExceptionResponse(request, response, ex, logger);
        }
    }*/
}
